<?php

use common\enums\AccountTypeEnum;
use common\helpers\Html;
use common\helpers\Url;
use common\models\backend\AdminBank;
use common\models\member\Recharge;
use yii\widgets\ActiveForm;

$form = ActiveForm::begin([
    'id' => $model->formName(),
    // 'enableAjaxValidation' => true,
    // 'validationUrl' => Url::to(['handle', 'id' => $id]),
    // 'fieldConfig' => [
    //     'template' => "<div class='col-sm-2 text-right'>{label}</div><div class='col-sm-10'>{input}\n{hint}\n{error}</div>",
    // ]
]);
?>

<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<div class="modal-body">
    <div class="first">
        <table class="table table-striped table-bordered detail-view">
            <tbody>
                <tr>
                    <td>订单编号</td>
                    <td><?= Html::encode($model['order_no']) ?></td>
                    <td>会员账号</td>
                    <td><?= Html::encode($model['member']['username']) ?></td>
                </tr>
                <tr>
                    <td>充值方式</td>
                    <td><?= Html::encode(AccountTypeEnum::getMap()[$model['type']]) ?></td>
                    <td>金额</td>
                    <td><?= Html::encode($model['amount']) ?></td>
                </tr>
                <tr>
                    <td>收款名称</td>
                    <td><?= Html::encode($model['open_bank']) ?></td>
                    <td>收款姓名</td>
                    <td><?= Html::encode($model['bank_user_name']) ?></td>
                </tr>
                <tr>
                    <td>收款账号</td>
                    <td><?= Html::encode($model['card_number']) ?></td>
                    <td>提交时间</td>
                    <td><?= Html::encode($model['created_at']) ?></td>
                </tr>
                <tr>
                    <td>处理结果：</td>
                    <td>
                        <select name="type" id="type" class="zhi">
                            <option value="2">批准</option>
                            <option value="3">不批准</option>
                            <option id="abc" class="hidden" value="<?= $model->id ?>"><?= $model->id ?></option>
                        </select>
                    </td>
                    <td id="name" style="display: none;">请说明原因：</td>
                    <td id="bz" style="display: none;"><textarea id="text"></textarea></td>
                </tr>
            </tbody>
        </table>
    </div>

</div>
<div class="modal-footer">
    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
    <button type="button" class="btn btn-success bc">保存</button>

    <!-- <button class="btn btn-primary tijiao"  type="submit">下一步</button> -->
</div>
<script type="text/javascript">
    $("#type").change(function() {
        var type = $('#type').val();
        if (type == 3) {
            $('#bz').show();
            $('#name').show();
        } else {
            $('#name').hide();
            $('#bz').hide();

        }

    });

    $(document).on('click', '.bc', function() {
        var id = $("#abc").val();
        var url = '<?= Url::to(['view']) ?>';
        var type = $('#type').val();
        var text = '';
        if (type == 2) {
            var url = '<?= Url::to(['check-account']) ?>';
        } else {
            var url = '<?= Url::to(['refuse']) ?>';
            text = $("#text").val();
        }
        $.post(url, {
            id: id,
            con: text
        }, function(data) {

        });
    });
</script>